//
//  STSettingViewController.m
//  shitong
//
//  Created by yyx on 15/5/31.
//  Copyright (c) 2015年 shitong. All rights reserved.
//

#import "STSettingViewController.h"
#import "UIView+MJ.h"

#define STMargin 30
// 获得RGB颜色
#define STColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

@interface STSettingViewController ()<UITextFieldDelegate>

@end

@implementation STSettingViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = STColor(236, 236, 236);
    
    self.title = @"设置";

    [self setUpSubview];

    
}

- (void)setUpSubview
{
    
    NSArray *homeArray = [NSArray arrayWithObjects:@"理财室1", @"理财室2", @"理财室3", @"理财室4", @"分行",nil];
    
    for (int i = 0; i < homeArray.count; i ++) {
        
        UIView *homeView = [[UIView alloc] init];
        CGFloat homeView1X = STMargin;
        CGFloat homeView1H = STMargin * 4;
        CGFloat homeView1Y = (self.navigationController.navigationBar.height + STMargin) + i * (homeView1H + 10);
        CGFloat homeView1W = self.view.width - STMargin * 2;
        homeView.frame = CGRectMake(homeView1X, homeView1Y, homeView1W, homeView1H);
        homeView.backgroundColor = [UIColor lightGrayColor];
        [self.view addSubview:homeView];
        
        CGFloat homeLabelX = 0;
        CGFloat homeLabelY = 0;
        CGFloat homeLabelW = homeView1W;
        CGFloat homeLabelH = STMargin;
        UILabel *homeLabel = [[UILabel alloc] initWithFrame:CGRectMake(homeLabelX, homeLabelY, homeLabelW, homeLabelH)];
        homeLabel.font = [UIFont systemFontOfSize:20];
        homeLabel.backgroundColor = [UIColor clearColor];
        homeLabel.textColor = [UIColor blackColor];
        homeLabel.textAlignment = NSTextAlignmentLeft;
        homeLabel.text = [homeArray objectAtIndex:i];
        [homeView addSubview:homeLabel];
        
        CGFloat ipLabelX = 0;
        CGFloat ipLabelY = CGRectGetMaxY(homeLabel.frame)+1;
        CGFloat ipLabelW = homeView1W;
        CGFloat ipLabelH = STMargin*1.5;
        UILabel *ipLabel = [[UILabel alloc] initWithFrame:CGRectMake(ipLabelX, ipLabelY, ipLabelW, ipLabelH)];
        ipLabel.font = [UIFont systemFontOfSize:20];
        ipLabel.backgroundColor = [UIColor whiteColor];
        ipLabel.textColor = [UIColor blackColor];
        ipLabel.textAlignment = NSTextAlignmentLeft;
        ipLabel.text = @"  IP:";
        [homeView addSubview:ipLabel];
        
        // ip输入框
        CGFloat ipTextFieldX = STMargin*2;
        CGFloat ipTextFieldY = ipLabelY;
        CGFloat ipTextFieldW = ipLabelW-STMargin*2;
        CGFloat ipTextFieldH = ipLabelH;
        UITextField *ipTextField = [[UITextField alloc] initWithFrame:CGRectMake(ipTextFieldX, ipTextFieldY, ipTextFieldW, ipTextFieldH)];
        ipTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 30)];
        ipTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        ipTextField.leftViewMode = UITextFieldViewModeAlways;
        ipTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
        ipTextField.font = [UIFont systemFontOfSize:18.0];
        ipTextField.backgroundColor = [UIColor whiteColor];
        ipTextField.textColor = [UIColor blackColor];
        ipTextField.placeholder = NSLocalizedString(@"请输入IP地址", @"请输入IP地址");
        ipTextField.returnKeyType = UIReturnKeyDone;
        ipTextField.delegate = self;
        ipTextField.borderStyle = UITextBorderStyleNone;
        [homeView addSubview:ipTextField];
        ipTextField.tag = 100+i;
        
        CGFloat numberLabelX = 0;
        CGFloat numberLabelY = CGRectGetMaxY(ipLabel.frame)+1;
        CGFloat numberLabelW = homeView1W;
        CGFloat numberLabelH = ipLabelH;
        UILabel *numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(numberLabelX, numberLabelY, numberLabelW, numberLabelH)];
        numberLabel.font = [UIFont systemFontOfSize:20];
        numberLabel.backgroundColor = [UIColor whiteColor];
        numberLabel.textColor = [UIColor blackColor];
        numberLabel.textAlignment = NSTextAlignmentLeft;
        numberLabel.text = @" 编号:";
        [homeView addSubview:numberLabel];
        
        // 员工编号输入框
        CGFloat numberTextFieldX = ipTextFieldX;
        CGFloat numberTextFieldY = numberLabelY;
        CGFloat numberTextFieldW = ipTextFieldW;
        CGFloat numberTextFieldH = numberLabelH;
        UITextField *numberTextField = [[UITextField alloc] initWithFrame:CGRectMake(numberTextFieldX, numberTextFieldY, numberTextFieldW, numberTextFieldH)];
        numberTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 30)];
        numberTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        numberTextField.leftViewMode = UITextFieldViewModeAlways;
        numberTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
        numberTextField.font = [UIFont systemFontOfSize:18.0];
        numberTextField.backgroundColor = [UIColor whiteColor];
        numberTextField.textColor = [UIColor blackColor];
        numberTextField.placeholder = NSLocalizedString(@"请输入编号", @"请输入编号");
        numberTextField.returnKeyType = UIReturnKeyDone;
        numberTextField.delegate = self;
        numberTextField.borderStyle = UITextBorderStyleNone;
        [homeView addSubview:numberTextField];
        numberTextField.tag = 1000+i;
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
